<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>后台登录</title>
    <link rel="icon" href="${pageContext.request.contextPath}/lib/static/login/images/favicon.ico">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/lib/static/login/css/login.css" type="text/css">
    <script src="${pageContext.request.contextPath}/lib/static/common/js/jquery.min.js"></script>
    <script src="${pageContext.request.contextPath}/lib/layui/layui.js"></script>
</head>
<body>

<div class="login">
    <div class="message">思远OA-管理登录</div>
    <form method="post">
        <input id="username" placeholder="用户名" required type="text">
        <hr class="hr15">
        <input id="password" placeholder="密码" required type="password">
        <hr class="hr15">
        <input type="button" value="登录" id="submitBtn">
        <hr class="hr20">
    </form>
</div>
<script>
    layui.use('layer');

    $(function () {
        $("#submitBtn").click(doLogin);
    });
    //登录
    function doLogin(){
        var params={
            username:$("#username").val(),
            password:$("#password").val()
        }
        var url="${pageContext.request.contextPath}/doLogin";
        $.post(url,params,function(data){
            var result = JSON.parse(data);
            if(result.code==0){
                //跳转到indexUI对应的页面
                location.href="index?t="+Math.random(); /*避免浏览器缓冲JS*/
            }else{
                /*弹出框提示*/
                layer.msg(result.msg, {icon: 5});
            }
            return false;//防止刷新时重复提交
        });
    }
</script>
</body>
</html>